import requests
# UA伪装:让爬虫对应的请求载体的身份标识伪装成某一款浏览器

if __name__ == '__main__':
    # UA伪装
    headers = {
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36'
    }
    url = 'https://www.sogou.com/web'
    keyW = input('请输入查询信息：')
    param = {
        'query':keyW
    }
    response = requests.get(url=url,params=param,headers=headers)
    page_text = response.text
    file_name = keyW+'.html'
    f = open(file_name,'w',encoding='utf-8')
    f.write(page_text)
    f.close()
    print(f'{file_name}爬取完毕！')

